import QtQuick 2.0

Rectangle {
    id: relay

    //自定义信号
    signal messageReceived(string message, string sender)

    //将一个信号绑定到多个槽函数
    //信号到信号的连接与此相同
    Component.onCompleted: {
        relay.messageReceived.connect(sendToLiLei)      // 连接信号和方法
        relay.messageReceived.connect(sendToHanMeimei)  // 连接信号和方法
        relay.messageReceived("Welcome to join us（QML分享&交流）", "群主")  // 发射信号
    }

    function sendToLiLei(message, sender) {
        console.log("LiLei new message: " + message + ", 发送者:" + sender)
    }

    function sendToHanMeimei(message, sender) {
        console.log("HanMeimei new message: " + message + ", 发送者:" + sender)
    }
}
